<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/validate.jsp"%>
<%
	String key = input.getDesc("key", "");
	List<Map> sList = null;
	if(DateUtil.parseDate(key) == null){
		sList = QBuilder.db("basedb").queryHql("select new map(e.avatar as avatar, s.deptId as dept_id, s.deptName as title, s.doctorId as id, s.doctorName as name, (case when e.specialty = null then '暂无' when e.specialty = '' then '暂无' else e.specialty end) as specialty, (case when e.content = null then '暂无' when e.content = '' then '暂无' else e.content end) as content) from Schedule s, Expert e where s.doctorId = e.expertId and s.hospital = " + hospital + " and e.hospital = " + hospital + " and s.status = " + STATUS_ENABLE + " and e.status = " + STATUS_ENABLE + " and s.registerType = " + EXPERT_NO + " and (s.doctorName like '%" + key + "%' or s.deptName like '%" + key + "%') group by e.avatar, s.deptId, s.deptName, s.doctorId, s.doctorName, e.specialty, e.content order by s.deptName asc, s.doctorName asc, s.date asc");
	}else{
		sList = QBuilder.db("basedb").queryHql("select new map(e.avatar as avatar, s.deptId as dept_id, s.deptName as title, s.doctorId as id, s.doctorName as name, (case when e.specialty = null then '暂无' when e.specialty = '' then '暂无' else e.specialty end) as specialty, (case when e.content = null then '暂无' when e.content = '' then '暂无' else e.content end) as content) from Schedule s, Expert e where s.doctorId = e.expertId and s.hospital = " + hospital + " and e.hospital = " + hospital + " and s.status = " + STATUS_ENABLE + " and e.status = " + STATUS_ENABLE + " and s.registerType = " + EXPERT_NO + " and s.date like '%" + key + "%' group by e.avatar, s.deptId, s.deptName, s.doctorId, s.doctorName, e.specialty, e.content order by s.deptName asc, s.doctorName asc");
	}
	if(sList == null){
		setErrcode(msg, FAILURE);
	}else if(sList.size() == 0){
		setErrcode(msg, NO_RESULT);
	}else{
		msg.put("data", sList);
	}
	Tools.encryptPrint(out, msg);
%>
